package anthology.daily_question._25_01;

import java.util.PriorityQueue;

//https://leetcode.cn/problems/minimum-operations-to-exceed-threshold-value-ii/description/?envType=daily-question&envId=2025-01-15
public class _3066超过阈值的最少操作数2 {
    class Solution {
        public int minOperations(int[] nums, int k) {
            PriorityQueue<Long> pq = new PriorityQueue<>();
            int res = 0;
            for(long i : nums){
                pq.offer(i);
            }
            while(pq.peek() < k){
                long x = pq.poll(), y = pq.poll();
                pq.offer(x + x + y);
                res++;
            }
            return res;
        }
    }
}
